package com.tiger.sso;

import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;

/**
 * 
 * @author andy
 *
 */
public class FilterConfigWritable implements FilterConfig {
	private final Map<String, String> initParameters = new LinkedHashMap<String, String>();
	private FilterConfig config;
	public FilterConfigWritable(FilterConfig config) {
		this.config = config;
		Enumeration<String> keys = config.getInitParameterNames();
		while(keys.hasMoreElements()) {
			String key = keys.nextElement();
			initParameters.put(key, config.getInitParameter(key));
		}
	}

	@Override
	public String getFilterName() {
		return config.getFilterName();
	}

	@Override
	public ServletContext getServletContext() {
		return config.getServletContext();
	}

	@Override
	public String getInitParameter(String name) {
		return initParameters.get(name);
	}

	@Override
	public Enumeration<String> getInitParameterNames() {
		return Collections.enumeration(initParameters.keySet());
	}

	public void setInitParameter(String name, String value) {
		initParameters.put(name, value);
	}
}
